package main

import (
	"log"
	"reflect"
)

//反射修改值
//必须是指针类型

func main() {
	var num float64 = 3.14
	log.Printf("[origin value:%f]", num)

	pointer := reflect.ValueOf(&num)
	newValus := pointer.Elem()
	newValus.SetFloat(5.6)
	log.Printf("[new value:%f]", num)

	//panic: reflect: call of reflect.Value.Elem on float64 Value
	//pointer = reflect.ValueOf(num)
	//newValus = pointer.Elem()
	//newValus.SetFloat(8.98)
	//log.Printf("[new value:%f]", num)
}
